package ad_exercise_4.controller;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringReader;

/**
 * 
 * @author Sjaak Smetsers (number?)
 * @author Karen Berntsen (s0815799)
 * @author Erik Stens (s0615374)
 */
public class AD_exercise_4 {
	public static void main(String[] args) {
		long now = System.currentTimeMillis();
		// mainNaive("./resources/aaaaaaaaaaa.txt");
		// mainNaive("./src/ad_exercise_4/model/LZWTree.java");
		// mainNaive("C:/Users/Erik/Downloads/sanitair-set_Alphons (repaired).obj");
		// mainLZWTree("./resources/abacababa.txt");
		// mainLZWTree("./resources/aaaaaaaaaaa.txt");
		// mainLZWTree("./src/ad_exercise_4/model/LZWTree.java");
		mainLZWTree("C:/Users/Erik/Downloads/sanitair-set_Alphons (repaired).obj");
		System.out.println("The elapsed time is " + (System.currentTimeMillis() - now) + " milliseconds");
	}
	
	private static void mainNaive() {
		try {
			// String test_tekst = "abacababa";
			String test_tekst = "aaaaaaaaaaaaaaaaaaaaaa";
			StringReader input = new StringReader(test_tekst);
			LZWNaive lzwNaive = new LZWNaive();
			lzwNaive.compress(new ByteArrayInputStream(test_tekst.getBytes("UTF-8")));
		} catch (IOException e) {}
		
	}
	
	private static void mainNaive(String filename) {
		try {
			BufferedInputStream input = new BufferedInputStream(new FileInputStream(new File(filename)));
			LZWNaive lzwNaive = new LZWNaive();
			lzwNaive.compress(input);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	private static void mainLZWTree() {
		try {
			// String test_tekst = "abacababa";
			String test_tekst = "aaaaaaaaaaaaaaaaaaaaaa";
			LZWUtil.compress(new ByteArrayInputStream(test_tekst.getBytes("UTF-8")));
		} catch (IOException e) {
			
		}
	}
	
	private static void mainLZWTree(String filename) {
		try {
			BufferedInputStream input = new BufferedInputStream(new FileInputStream(new File(filename)));
			LZWUtil.compress(input);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
